#include <stdio.h>
#include <stdlib.h>
#include <math.h>

//https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded?tpId=37&&tqId=21296&rp=1&ru=/ta/huawei&qru=/ta/huawei/question-ranking

int LeapYear(int year){
    if((year % 100 != 0 && year % 4 == 0) || (year % 400 == 0)){
        return 1;
    }
    return 0;
}

int main() {
    int year = 0;
    int month = 0;
    int day = 0;
    scanf("%d%d%d", &year, &month, &day);
    int MonthDay[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
    if (LeapYear(year) == 1 && month > 2) {
        day++;
    }
    printf("%d", MonthDay[month - 1] + day);
    return 0;
}